package org.sauceggplant;

import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;

/**
 * 界面
 *
 * @author jacob
 * @version 0.1
 */
public class EdFrame extends JFrame {

    public EdFrame() {
        this.setTitle("加解密");
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setLayout(new BorderLayout());

        JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
        EPanel ePanel = new EPanel();
        tabbedPane.addTab("加密", ePanel);
        DPanel dPanel = new DPanel();
        tabbedPane.addTab("解密", dPanel);
        tabbedPane.addChangeListener(new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
                if(((JTabbedPane)e.getSource()).getSelectedIndex() == 0) {
                    ePanel.geteFileChooser().updateUI();
                } else {
                    dPanel.getdFileChooser().updateUI();
                }
            }
        });
        this.getContentPane().add(tabbedPane, BorderLayout.CENTER);

        this.setPreferredSize(new Dimension(800, 600));
        this.setSize(new Dimension(800, 600));
        this.setLocationRelativeTo(null);
        this.pack();
        this.setVisible(true);
    }
}
